<template>
	<div>
		<div style="margin: 20px;"></div>
		<el-form>
			请输入要查询的设备编号:
			<el-input style="width: 40%;margin-left: 30%;margin-right: 30%;" v-model="inputId"></el-input>
		</el-form>
		<el-button type="primary" @click.prevent="addEquipments()">提交</el-button><br />
		查询结果
		<el-form label-position="left" label-width="80px" ref="tableData" :model="tableData">

			<el-form-item label="设备编号" prop="eId">
				<el-input v-model="tableData.eId"></el-input>
			</el-form-item>
			<el-form-item label="设备名称" prop="eName">
				<el-input v-model="tableData.eName"></el-input>
			</el-form-item>
			<el-form-item label="设备图片信息" prop="imageUrl">
				<el-input v-model="tableData.imageUrl"></el-input>
			</el-form-item>
			<el-form-item label="设备描述信息" prop="eDescription">
				<el-input v-model="tableData.eDescription"></el-input>
			</el-form-item>
			<el-form-item label="设备分类Id" prop="categoryId">
				<el-input v-model="tableData.categoryId"></el-input>
			</el-form-item>
		</el-form>

		<!-- 		<el-button @click="resetForm('tableData')">重置</el-button> -->
		</el-form-item>
	</div>
</template>

<script>
	import request from '@/utils/axios/request.js'
	export default {
		data() {
			return {
				inputId: '',
				tableData: {
					eId: '',
					eName: '',
					imageUrl: '',
					eDescription: '',
					categoryId: ''
				}
			};
		},
		methods: {

			addEquipments: function() {
				alert('即将为您查询设备编号为' + this.inputId + '的设备信息');
				//let _this = this
				//let formData = JSON.stringify(this.tableData)
				//console.log(formData)
				console.log(this.inputId)
				request({
					method: 'get',
					url: '/equipments/' + this.inputId,
					contentType: "application/json",
					// params:{
					// 	eId: this.inputId
					// },
					// header: {
					// 	// 'Content-Type': 'application/x-www-form-urlencoded'
					// 	"Content-Type": "application/json",

					// 	// "Content-Type": "multipart/form-data"
					// },

					// data: this.formData


				}).then((res) => {
					// var jsonObj = JSON.parse(JSON.stringify(res.data.data[0]));
					// console.log(this.tableData)
					// console.log("提交成功")
					console.log(res)
					if (res.data.code==100) {
						this.tableData.eId = res.data.data.eId
						this.tableData.eName = res.data.data.eName
						this.tableData.imageUrl = res.data.data.imageUrl
						this.tableData.eDescription = res.data.data.eDescription
						this.tableData.categoryId = res.data.data.categoryId
						
					} else if(res.data.code==101){
						alert('查询失败，不存在编号为'+this.inputId+'的设备')
					}
				
				})
			}
		}
	}
</script>

<style>
	.el-form-item {
		width: 40%;
		margin-left: 30%;
		margin-right: 30%;
	}
</style>